import React, { Component } from 'react'
import { Route, Redirect } from 'react-router-dom'
import ROUTE_LIST from '../MyRouterList'
export default class MyRoute extends Component {
  render () {
    //接收数据
    const { cityList } = this.props
    return (
      <div>
        {/* 动态渲染路由 */}
        {
          ROUTE_LIST.map((item, index) => {
            const MyComponent = item.component
            if (item.isRedirect) {
              return <Redirect to={item.to} key={index}></Redirect>
            }
            return (
              <Route
                path={item.path}
                render={(props) => <MyComponent cityList={cityList} {...props}></MyComponent>}
                key={index}
              >
              </Route>
            )
          })
        }
      </div>
    )
  }
}


